<template>
  <div>
    <!-- 面包屑导航栏 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card class="box-card">
      <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
      <div id="myChart" style="width: 600px; height: 400px"></div>
    </el-card>
  </div>
</template>

<script>
// 1. 引入 Eacharts
import * as echarts from 'echarts'
export default {
  data() {
    return {}
  },
  created() {},
  // DOM 元素渲染完毕
  async mounted() {
    // 2. 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('myChart'))

    // 3. 准备数据和配置项
    const { data: res } = await this.$http.get('reports/type/1')
    if (res.meta.status !== 200) {
      return this.$message.error(res.meta.msg)
    }
    // console.log(res)
    // 4.  绘制图表
    myChart.setOption(res.data)
  }
}
</script>

<style lang="less" scoped></style>
